package com.peanut.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.domain.bo.TabSpecBO;
import com.peanut.domain.po.TabSpecPO;
import com.peanut.service.TabSpecService;
import com.peanut.mapper.TabSpecMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 张涛
* @description 针对表【tab_spec】的数据库操作Service实现
* @createDate 2022-05-25 16:00:46
*/
@Service
public class TabSpecServiceImpl extends ServiceImpl<TabSpecMapper, TabSpecPO>
    implements TabSpecService{

    @Resource
    private TabSpecMapper specMapper;

    @Override
    public int addSpec(TabSpecBO bo) {
        TabSpecPO spec = new TabSpecPO();
        BeanUtils.copyProperties(bo,spec);
        return specMapper.insert(spec);
    }

    @Override
    public Page<TabSpecPO> findAll(Integer pageNumber, Integer pageSize) {
        Page<TabSpecPO> page = new Page<>(pageNumber,pageSize);
        Page<TabSpecPO> spec = specMapper.selectPage(page, null);
        return spec;
    }

    @Override
    public int updateSpec(TabSpecBO bo) {
        TabSpecPO spec = new TabSpecPO();
        BeanUtils.copyProperties(bo,spec);
        return specMapper.updateById(spec);
    }

    @Override
    public List<TabSpecPO> getSpec() {
        List<TabSpecPO> list = specMapper.selectList(null);
        return list;
    }

    @Override
    public int deleteSpec(Long specId) {
        return specMapper.deleteById(specId);
    }
}




